package com.reggie.common.util;

import com.reggie.common.enums.ResponseCode;
import com.reggie.common.exception.ReggieException;

import java.util.Objects;

/**
 * @author yth
 * @since 2023-11-12-0:19
 */
public class AssertUtils {

    public static void nonNull(Object object, ResponseCode responseCode) {
        if (Objects.isNull(object)) {
            throw new ReggieException(responseCode, object + "should nonNull");
        }
    }

    public static void nonNull(Object object, ResponseCode responseCode, String message) {
        if (Objects.isNull(object)) {
            throw new ReggieException(responseCode, message);
        }
    }

    public static void isNull(Object object, ResponseCode responseCode) {
        if (Objects.nonNull(object)) {
            throw new ReggieException(responseCode, object + "should isNull");
        }
    }

    public static void isNull(Object object, ResponseCode responseCode, String message) {
        if (Objects.nonNull(object)) {
            throw new ReggieException(responseCode, message);
        }
    }

    public static void equals(Object expected, Object actual, ResponseCode responseCode) {
        if (!Objects.equals(expected, actual)) {
            throw new ReggieException(responseCode, expected + "should be equal to" + actual);
        }
    }

    public static void equals(Object expected, Object actual, ResponseCode responseCode, String message) {
        if (!Objects.equals(expected, actual)) {
            throw new ReggieException(responseCode, message);
        }
    }

    public static void notEquals(Object expected, Object actual, ResponseCode responseCode) {
        if (Objects.equals(expected, actual)) {
            throw new ReggieException(responseCode, expected + "should be not equal to" + actual);
        }
    }

    public static void notEquals(Object expected, Object actual, ResponseCode responseCode, String message) {
        if (Objects.equals(expected, actual)) {
            throw new ReggieException(responseCode, message);
        }
    }

    private AssertUtils() {
    }
}
